package com.xbongbong.saas.script.tempenum;

import com.xbongbong.i18n.util.I18nMessageUtil;
import com.xbongbong.paas.enums.ComboTypeEnum;
import com.xbongbong.paas.field.FieldAttrEntity;
import com.xbongbong.paas.field.ItemPoJo;
import com.xbongbong.paas.field.LinkDetailPojo;
import com.xbongbong.pro.enums.SaasMarkEnum;
import com.xbongbong.saas.constant.StringConstant;
import com.xbongbong.saas.enums.XbbRefTypeEnum;
import com.xbongbong.saas.enums.business.CompetitorEnum;
import com.xbongbong.saas.enums.dictionary.CompetitorScaleEnum;
import lombok.Getter;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @author: yingjf
 * @date: 2022/8/15 14:29
 * @description: 竞争对手
 */
@Getter
public enum TempCompetitorEnum {
    //基本信息
    BASE_INFO(CompetitorEnum.BASE_INFO),
    //竞争对手名称
    NAME(CompetitorEnum.NAME),
    //企业规模
    SCALE(CompetitorEnum.SCALE),
    //公司简介
    INSTRUCTION(CompetitorEnum.INSTRUCTION),
    //企业地址
    ADDRESS(CompetitorEnum.ADDRESS),
    //企业官网
    WEBSITE(CompetitorEnum.WEBSITE),
    //可见部门
    VISBLE_DEPT(CompetitorEnum.VISBLE_DEPT),
    //可见人
    VISBLE_USER(CompetitorEnum.VISBLE_USER),
    // 系统信息
    SYSTEM_INFO(CompetitorEnum.SYSTEM_INFO),
    //创建人
    CREATOR_ID(CompetitorEnum.CREATOR_ID),
    //创建时间
    ADD_TIME(CompetitorEnum.ADD_TIME),
    //更新时间
    UPDATE_TIME(CompetitorEnum.UPDATE_TIME),
    ;

    private CompetitorEnum anEnum;

    TempCompetitorEnum(CompetitorEnum anEnum){
        this.anEnum = anEnum;
    }

    public static List<TempCompetitorEnum> getAllEnum() {
        List<TempCompetitorEnum> list = new ArrayList<>();
        Collections.addAll(list, values());
        return list;
    }

    public static void initName(FieldAttrEntity fieldAttrEntity) {
        LinkDetailPojo linkDetailPojo = new LinkDetailPojo();
        linkDetailPojo.setBusinessType(XbbRefTypeEnum.COMPETITOR.getCode());
        linkDetailPojo.setSubBuisenssType(XbbRefTypeEnum.COMPETITOR.getCode());
        linkDetailPojo.setSaasMark(SaasMarkEnum.SAAS.getCode());
        linkDetailPojo.setAttr(NAME.getAnEnum().getAttr());
        fieldAttrEntity.setLinkDetail(linkDetailPojo);
        fieldAttrEntity.setNoRepeat(0);
        fieldAttrEntity.setShowRemove(0);
        fieldAttrEntity.setIsForbidden(0);
    }

    public static void initScale(FieldAttrEntity fieldAttrEntity) {
        CompetitorScaleEnum[] values = CompetitorScaleEnum.values();
        List<ItemPoJo> items = new ArrayList<>();
        for (CompetitorScaleEnum competitorScaleEnum : values) {
            ItemPoJo itemPoJo = new ItemPoJo();
            itemPoJo.setNoMove(1);
            itemPoJo.setNoDel(1);
            itemPoJo.setNoEdit(1);
            itemPoJo.setText(competitorScaleEnum.getName());
            itemPoJo.setValue(competitorScaleEnum.getCode());
            items.add(itemPoJo);
        }
        fieldAttrEntity.setItems(items);
        fieldAttrEntity.setComboType(ComboTypeEnum.CUSTOM.getType());
        fieldAttrEntity.setDictionaryFlag(1);
        fieldAttrEntity.setEditable(1);
        fieldAttrEntity.setItemBanDefault(0);
        fieldAttrEntity.setShowEditable(1);
        fieldAttrEntity.setShowRemove(1);
        fieldAttrEntity.setDisableListSort(1);
    }
    public static void initInstruction(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setEditable(1);
        fieldAttrEntity.setDisableListSort(1);
    }
    public static void initAddress(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setEditable(1);
        fieldAttrEntity.setDisableListSort(1);
    }
    public static void initWebsite(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setEditable(1);
        fieldAttrEntity.setDisableListSort(1);
    }

    public static void initVisbleDept(FieldAttrEntity fieldAttrEntity){
        fieldAttrEntity.setEditable(1);
        fieldAttrEntity.setShowEditable(0);
        fieldAttrEntity.setIsForbidden(0);
        fieldAttrEntity.setIsForbidden(0);
    }

    public static void initVisbleUser(FieldAttrEntity fieldAttrEntity){
        fieldAttrEntity.setEditable(1);
        fieldAttrEntity.setShowEditable(0);
        fieldAttrEntity.setIsForbidden(0);
        fieldAttrEntity.setIsForbidden(0);
    }
    public static void initCreatorId(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setEditable(0);
        fieldAttrEntity.setUnableEditMemo(I18nMessageUtil.getMessage(StringConstant.AUTO_GEN_FIELD));
        fieldAttrEntity.setIsForbidden(0);
    }
    public static void initAddTime(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setEditable(0);
        fieldAttrEntity.setUnableEditMemo(I18nMessageUtil.getMessage(StringConstant.AUTO_GEN_FIELD));
        fieldAttrEntity.setIsForbidden(0);
    }
    public static void initUpdateTime(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setEditable(0);
        fieldAttrEntity.setUnableEditMemo(I18nMessageUtil.getMessage(StringConstant.AUTO_GEN_FIELD));
        fieldAttrEntity.setIsForbidden(0);
    }
}
